package com.gne.data.platform.controller;

import com.gne.data.platform.dao.UserDao;
import com.gne.data.platform.pojo.Article;
import com.gne.data.platform.util.RedisUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    UserDao userDao;
    
    @Resource
    RedisUtil redisUtil;
    
    @Resource
    private MongoTemplate mongoTemplate;

    @RequestMapping("/say")
    @ResponseBody
    public String say(String name) {
        System.out.println(name + "::cccc");
        return "你好";
    }

    @RequestMapping("/say2")
    @ResponseBody
    //localhost:8080/hello/say2
    public String say2() {
//        userDao.save("掌声",11);
        Article article = new Article();
        article.setTitle("你好");
        mongoTemplate.save(article);
        return "你好";
    }
    @RequestMapping("/say3")
    @ResponseBody
    //localhost:8080/hello/say3
    public String say3() {
    	redisUtil.set("my2", 1234);
    	return "你好";
    }
}
